#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#include <windows.h>
#include <time.h>

int main()
{
	int i,j;
	int x=5;
	int y=5;
	int isfired=0;
	int iskilled=0;
	char input;
	int p,q;
	int score=0;
	int oh=1;
	int a=5;
	
	scanf("%c",&input);
	while(1)
	{	
		system("cls");
		if(iskilled==0||oh==0)
		{
			
			for(i=0;i<a;i++)
				printf(" ");
			printf("+\n");
			
		}
		
		if(isfired==0){		
			for(i=0;i<x;i++)
			{	printf("\n");
			}
		}
		
		if(isfired==1)
		{			
			for(i=0;i<x;i++)
			{
				for(j=0;j<y;j++)
				{printf(" ");}	
				printf("  |\n");
			}
			isfired=0;
			
			if(y+2==a)
			{	
				iskilled=1;
			score=score+1;

			srand(time(0));
			a = rand() % 40 + 4;

			oh=0;
			}
		}
		
		for(j=0;j<y;j++)
			printf(" ");
		printf("  *\n");
		for(j=0;j<y;j++)
		{	printf(" ");	}
		printf("*****\n");
		for(j=0;j<y;j++)
		{	printf(" ");	}
		printf(" * * \n");
		for(j=0;j<y;j++)
		{	printf(" ");	}
		printf(" \n ");
		for(j=0;j<y;j++)
		{	printf(" ");	}
		printf(" \n ");
		for(j=0;j<y;j++)
		{	printf(" ");	}
		printf(" 得分:%d",score);
	
		input =getch ();		
		if(input=='s')
		{ x++; }
		if(input=='w')
		{ x--; }
		if(input=='a')
		{ y--; }
		if(input=='d')
		{ y++; }
		if(input==' ')
		{isfired=1;}
	}	
	return 0;
}

